﻿package com.ghost.utils
{
    import com.ghost.interfaces.Ibaseui;
    import com.ghost.model.Global_data;
    
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.system.*;
    import flash.text.*;
    import flash.utils.*;

    public class SystemStatus extends MovieClip implements Ibaseui
    {
        private var statTime:uint;
        private var timer:Timer;
        private var statFrame:uint = 0;
        private var tf:TextField;
		//public var __transitionManager:*;
        private static var _instance:SystemStatus;

        public function SystemStatus()
        {
            if (_instance != null)
            {
                throw new Error("singleton");
            }
            addEventListener(Event.ENTER_FRAME, this._onEnterFrame);
            this.timer = new Timer(1000);
            this.timer.addEventListener(TimerEvent.TIMER, this.onTimer);
            this.timer.start();
            this.statTime = getTimer();
            this.tf = new TextField();
            this.tf.border = true;
            this.tf.backgroundColor = 16777215;
            this.tf.background = true;
            addChild(this.tf);
            this.tf.autoSize = TextFieldAutoSize.LEFT;
            this.tf.mouseEnabled = false;
            this.alpha = 0.5;
			onTimer(null);
            return;
        }// end function

        private function onTimer(event:TimerEvent) : void
        {
            var _loc_2:* = getTimer();
            var _loc_3:* = _loc_2 - this.statTime;
            var _loc_4:* = this.statFrame / _loc_3 * 1000;
            this.statTime = _loc_2;
            this.statFrame = 0;
            this.tf.text = "fps:" + _loc_4 + "\n";
            this.tf.appendText("vmVersion:" + System.vmVersion + "\n");
            this.tf.appendText("player:" + Capabilities.version + " ");
            if (Capabilities.isDebugger)
            {
                this.tf.appendText("debug");
            }
            this.tf.appendText("\nmem:" + System.totalMemory / 1024 / 1024 + "MB\n");
            this.tf.appendText("os:" + Capabilities.os + "\n");
            this.tf.appendText("os language:" + Capabilities.language + "\n");
            this.tf.appendText("pageCode:" + System.useCodePage + "\n");
            this.tf.appendText("playerType:" + Capabilities.playerType + "\n");
            this.tf.appendText("screenResolution:" + Capabilities.screenResolutionX + "x" + Capabilities.screenResolutionY + "\n");
            return;
        }// end function

        private function _onEnterFrame(event:Event) : void
        {
             var _loc_3:* = this.statFrame + 1;
            statFrame = _loc_3;
            return;
        }// end function

        public static function getInstance() : SystemStatus
        {
            if (_instance == null)
            {
                _instance = new SystemStatus;
            }
            return _instance;
        }// end function
		public function reflash_x_y(e:*):void
		{
			this.x = 0;
			this.y = 0;
		}
		public function hide():void
		{
			this.visible = false;
		}
		public function show():void
		{
			this.visible = true;
		}

    }
}
